#include "poparser.h"
#include <iostream>
using namespace std;
static const char *argv1[] = { //这是模拟的命令行参数
  "program name", //这是程序名，不是选项或参数，分析器不分析位置0
  "-ff2",
  "-tt",
  "non-option-arg1",
  "-yddir1",
  "dir2",
  "-h",
  "--to",
  "to",
  "--version",
  "non-option-arg2",
  "-pp1",
  "-f",
  "f1",
  "-V",
  "--pattern=pattern1",
  "-T",
  "--from=from",
  "non-option-arg3",
  "-FF",
  "--",
  "non-option arg4",
};
constexpr int argc1 = (sizeof (argv1) / sizeof (*argv1));
bool
show_usage (std::vector<std::string> &args)
{
  cout << "show_usage." << endl;
  return true;
}
bool
installself (std::vector<std::string> &args)
{
  cout << "installself." << endl;
  return true;
}
bool
show_version (std::vector<std::string> &args)
{
  cout << "show_version." << endl;
  return true;
}
int YesNo = 0;
int TestMode = 0;
int Verbose = 0;
int
main (int argc, char **argv)
{
  auto *opt = new POParser (
      { { "f",
          { "from" },
          POParser::NumOfArg::Has,
          false,
          nullptr,
          0,
          nullptr },
        { "t", { "to" }, POParser::NumOfArg::Has, false, nullptr, 0, nullptr },
        { "h",
          { "help", "HELP" },
          POParser::NumOfArg::No,
          false,
          nullptr,
          0,
          show_usage },
        { "y", { "" }, POParser::NumOfArg::No, false, &YesNo, 1, nullptr },
        { "d",
          { "dir", "DIR" },
          POParser::NumOfArg::Has,
          true,
          nullptr,
          0,
          nullptr },
        { "p",
          { "pattern" },
          POParser::NumOfArg::Has,
          true,
          nullptr,
          0,
          nullptr },
        { "F", {}, POParser::NumOfArg::Has, true, nullptr, 0, nullptr },
        { "T", {}, POParser::NumOfArg::No, false, &TestMode, 1, nullptr },
        { "V",
          { "version" },
          POParser::NumOfArg::No,
          false,
          nullptr,
          0,
          show_version },
        { "v", {}, POParser::NumOfArg::No, false, &Verbose, 0, nullptr },
        { "",
          { "installself", "INSTALLSELF" },
          POParser::NumOfArg::No,
          false,
          nullptr,
          0,
          installself } });

  cout << "TestMode:" << TestMode << endl;
  cout << "YesNo:" << YesNo << endl;
  cout << "Verbose:" << Verbose << endl;
  cout << "*opt before parse" << endl<<*opt;
  (*opt).parse (argc1, (char **)argv1);
  cout << "*opt after parse" << endl<<*opt;
  POParser opt1;
  opt1 = std::move (*opt);
  delete opt;
  cout << "opt1" << endl << opt1;
  opt1.remove ("--");
  cout << "opt1 remove '--'" << endl << opt1;
  opt1.append ("--");
  cout << "opt1 append '--'" << endl << opt1;
  opt1.append ("--", "append");
  cout << "opt1 append '--' \"append\"" << endl << opt1;
  opt1.append ("--");
  cout << "opt1 append '--'" << endl << opt1;
  opt1.append ("--", "append1");
  cout << "opt1 append '--' \"append1\"" << endl << opt1;

  cout << "TestMode:" << TestMode << endl;
  cout << "YesNo:" << YesNo << endl;
  cout << "Verbose:" << Verbose << endl;

  return 0;
}